package com.example.hangzhou.welbeing.mytestdemoapp.activity;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.StaggeredGridLayoutManager;
import android.view.LayoutInflater;
import android.view.View;

import com.example.hangzhou.welbeing.mytestdemoapp.R;
import com.example.hangzhou.welbeing.mytestdemoapp.adpater.MyAdapter;
import com.example.hangzhou.welbeing.mytestdemoapp.customView.MyRecyclerView;

import java.util.ArrayList;

import butterknife.Bind;
import butterknife.ButterKnife;
import cn.jesse.nativelogger.NLogger;

/**
 * 杭州惟君医疗科技有限公司15
 * Created by 20433 on 2018/4/17
 *
 * @desc 东风山河绿，春已不折柳，繁花看不尽，处处惹人留
 * @desc 佛祖镇楼，bug辟容易
 */

public class CustomRecyclerviewActivity extends AppCompatActivity {
    @Bind(R.id.activity_custom_recycler_01)
    MyRecyclerView activityCustomRecycler01;
    private StaggeredGridLayoutManager mLayoutManager;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_custom_recycler);
        ButterKnife.bind(this);
        mLayoutManager = new StaggeredGridLayoutManager(2,StaggeredGridLayoutManager.VERTICAL);
      //mLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
        MyAdapter mAdapter = new MyAdapter();

        // 设置布局管理器
        activityCustomRecycler01.setLayoutManager(mLayoutManager);
        // activityCustomRecycler01
        //View view = View.inflate(this,R.layout.my_recyclerview_empter,null);
        View header = LayoutInflater.from(this).inflate(R.layout.my_recyclerview_empter, activityCustomRecycler01, false);
        mAdapter.setHeaderView(header);
        mAdapter.addDatas(getData());
        //activityCustomRecycler01.setEmptyView(view);
        activityCustomRecycler01.setAdapter(mAdapter);


    }

    private ArrayList<String> getData() {
        ArrayList<String> data = new ArrayList<>();
        String temp = " item";
        for (int i = 0; i < 20; i++) {
            data.add(i + temp);
        }
        NLogger.e("TAG","mHeaderView==========data======"+data.size());
        return data;
    }

}
